<template>
    <div>
        <el-form :model="ruleForm" :rules="rules" ref="addSurveyForm" label-width="100px">
            <el-form-item label="调查名" prop="surveyName">
                <el-input v-model="ruleForm.surveyName" placeholder="调查名" maxlength="50" show-word-limit></el-input>
            </el-form-item>
            <el-form-item label="描述" prop="surveyTag">
                <el-input v-model="ruleForm.surveyTag" type="textarea" placeholder="描述" maxlength="125" show-word-limit></el-input>
            </el-form-item>
        </el-form>
        <br/>
        <el-row>
            <el-col :span="12">
                <questionnaire-select style="border: solid 1px #e6e6e6"></questionnaire-select>
            </el-col>
            <el-col :span="12">
                <user-select style="border: solid 1px #e6e6e6;"></user-select>
            </el-col>
        </el-row>
    </div>
</template>

<script>
    import UserSelect from '../user/UserSelect'
    import QuestionnaireSelect from '../questionnaire/QuestionnaireSelect'
    import {mapActions, mapGetters} from 'vuex';
    export default {
        name: "AddSurvey",
        components: {
            UserSelect,
            QuestionnaireSelect
        },
        methods: {
            ...mapActions('survey', [
                'setAddSurveyAct'
            ]),
        },
        watch: {
            'ruleForm.surveyName'() {
                let _this = this;
                let addSurvey = _this.$store.state.survey.addSurvey;
                addSurvey.name = _this.ruleForm.surveyName;
                _this.setAddSurveyAct(addSurvey);
            },
            'ruleForm.surveyTag'() {
                let _this = this;
                let addSurvey = _this.$store.state.survey.addSurvey;
                addSurvey.tag = _this.ruleForm.surveyTag;
                _this.setAddSurveyAct(addSurvey);
            }
        },
        data() {
            return {
                ruleForm: {
                    surveyName: "",
                    surveyTag: ""
                },
                rules: {
                    surveyName: [
                        { required: true, message: '必填', trigger: 'blur' }
                    ],
                    surveyTag: [
                        { required: true, message: '必填', trigger: 'blur' }
                    ]
                }
            }
        }
    }
</script>

<style scoped>

</style>
